﻿<UserControl x:Class="ContentViewLib.userContentView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:l="clr-namespace:ContentViewLib.Graphic"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="600">
    
    <UserControl.Resources>
        <DataTemplate x:Key="IDJmeno">
            <Border BorderBrush="Black" BorderThickness="10" Padding="10,10,10,10">
                <TextBlock Foreground="MediumBlue" FontFamily="Calibri" Text="{Binding Path=jmeno}" />
            </Border>
        </DataTemplate>

        <l:RowsConvertor x:Key="myConverter"/>
        <Style x:Key="myItemStyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="BorderBrush" Value="Black"/>
            <Setter Property="Margin" Value="1,1,1,0"/>
            <Setter Property="Padding" Value="2,2"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
            <Setter Property="VerticalContentAlignment" Value="Stretch"></Setter>
            <Setter Property="BorderThickness" Value="0.1,0.0,0.5,0.5"/>
            <Setter Property="Background">
                <Setter.Value>
                    <Binding RelativeSource="{RelativeSource Self}" Converter="{StaticResource myConverter}"/>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid>
        <ListView  x:Name="listView" ItemContainerStyle="{StaticResource myItemStyle}" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" ItemsSource="{Binding}" SelectionMode="Single" BorderThickness="1" ClipToBounds="False" PreviewMouseLeftButtonDown="listView_PreviewMouseLeftButtonDown" MouseEnter="listView_MouseEnter" MouseDoubleClick="listView_MouseDoubleClick">
            <ListView.ContextMenu>
                <ContextMenu Name="ctMenu">
                    <MenuItem Header="Smazat" Name="cmiSmazat" Click="cmiSmazat_Click_1"/>
                    <MenuItem Header="Vráceno" Name="cmiVraceno" Click="cmiVraceno_Click_1"/>
                </ContextMenu>
            </ListView.ContextMenu>
            <ListView.View >
                <GridView>
                    <GridViewColumn Header="ID objednávka" Width="0" DisplayMemberBinding="{Binding Path=id}" />
                    <GridViewColumn Header="Jméno"  DisplayMemberBinding="{Binding Path=jmeno}" Width="100" />
                    <GridViewColumn Header="Příjmení" DisplayMemberBinding="{Binding Path=prijmeni}" Width="100" />
                    <GridViewColumn Header="JIS karta" DisplayMemberBinding="{Binding Path=JIScislo}" Width="100" />
                    <GridViewColumn Header="Zboží" DisplayMemberBinding="{Binding Path=zboziNazev}" Width="250" />
                    <GridViewColumn Header="Kód zboží" DisplayMemberBinding="{Binding Path=zboziID}" Width="100" />
                    <GridViewColumn Header="Datum od" DisplayMemberBinding="{  Binding Path=od, StringFormat={}{0:d. M. yyyy}}" Width="150" />
                    <GridViewColumn Header="Datum do" DisplayMemberBinding="{Binding Path=do, StringFormat={}{0:d. M. yyyy}}" Width="150" />
                    <GridViewColumn Header="Cena" DisplayMemberBinding="{Binding Path=cena}" Width="150" />
                    <GridViewColumn Header="Poznámka" DisplayMemberBinding="{Binding Path=poznamka}" Width="100" />
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>

</UserControl>
